// 鼠标型号接口
interface MouseModel {
  id: string; // 型号标识
  displayName: string; // 显示名称
  configFile: string; // 配置文件名
}

// 配置文件类型
interface MouseConfigFile {
  default: {
    keysLayout: any;
    DefaultProfile: {
      mouseKeys: any;
      defaultConfig: any;
    };
    dpi: any;
    dpiConfig: any;
  };
}

// 鼠标型号映射表
export const MOUSE_MODELS: MouseModel[] = [
  { id: "SM809", displayName: "V1000", configFile: "mouse_info_v1000" },
];

// 默认配置
export const DEFAULT_MOUSE_MODEL: MouseModel = {
  id: "G3 A",
  displayName: "G3 A",
  configFile: "mouse_info_g3",
};

// 获取鼠标型号信息
export function getMouseModel(deviceName: string): MouseModel {
  const model = MOUSE_MODELS.find((model) => deviceName.includes(model.id));
  return model || DEFAULT_MOUSE_MODEL;
}

// 获取配置文件内容
export async function getMouseConfig(
  model: MouseModel
): Promise<MouseConfigFile> {
  try {
    const config = await import(`./${model.configFile}.json`);

    if (!config || !config.default) {
      throw new Error(`Invalid config file format for ${model.displayName}`);
    }

    return config as MouseConfigFile;
  } catch (error) {
    console.error(`Failed to load config for ${model.displayName}:`, error);
    throw error;
  }
}
